Skip to content

Embed and Marquee page blocks and icons for grid blocks#609

Merged
rajat1saxena merged 3 commits intomainfrom
rajat1saxena/issue608
Aug 11, 2025
Merged

Embed and Marquee page blocks and icons for grid blocks#609
rajat1saxena merged 3 commits intomainfrom
rajat1saxena/issue608

Conversation

@rajat1saxena
Copy link
Copy Markdown
Member

Also include a bug fix related to newsletter-signup block being shared

@vercel
Copy link
Copy Markdown

vercel bot commented Aug 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
courselit-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 11, 2025 7:18am

Comment thread packages/page-blocks/src/blocks/embed/admin-widget.tsx Fixed
Comment thread packages/page-blocks/src/blocks/embed/admin-widget.tsx Fixed
Comment thread packages/page-blocks/src/blocks/embed/admin-widget.tsx Fixed
Comment thread packages/page-blocks/src/blocks/embed/admin-widget.tsx Fixed
Comment thread packages/page-blocks/src/blocks/grid/admin-widget/item-editor.tsx Fixed
Comment on lines +106 to +107
processedSvg(svgCode, svgStyle) ||
'<div class="text-red-500">Invalid SVG</div>',

Check failure

Code scanning / CodeQL

DOM text reinterpreted as HTML High

DOM text
is reinterpreted as HTML without escaping meta-characters.

Copilot Autofix

AI 8 months ago

To fix this vulnerability, we must ensure that any SVG code rendered via dangerouslySetInnerHTML is properly sanitized. The best way is to use a well-known SVG sanitizer library (such as dompurify) to clean the SVG code before rendering. This should be done inside the processedSvg function, so that any SVG code passed to it is sanitized before being returned and rendered. The fix involves:

  • Importing dompurify (or similar) at the top of the file.
  • Modifying the processedSvg function to sanitize its output using DOMPurify.sanitize.
  • Ensuring that all SVG code rendered via dangerouslySetInnerHTML is sanitized.

All changes are to be made in packages/page-blocks/src/blocks/grid/admin-widget/svg-editor.tsx.


Suggested changeset 2
packages/page-blocks/src/blocks/grid/admin-widget/svg-editor.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/page-blocks/src/blocks/grid/admin-widget/svg-editor.tsx b/packages/page-blocks/src/blocks/grid/admin-widget/svg-editor.tsx
--- a/packages/page-blocks/src/blocks/grid/admin-widget/svg-editor.tsx
+++ b/packages/page-blocks/src/blocks/grid/admin-widget/svg-editor.tsx
@@ -9,3 +9,4 @@
 import { Check, Pencil, Trash, AlertCircle } from "lucide-react";
-import { validateSvg, processedSvg } from "../helpers";
+import { validateSvg } from "../helpers";
+import DOMPurify from "dompurify";
 
@@ -86,2 +87,11 @@
 
+    // Sanitized processedSvg implementation
+    function processedSvg(svgCode: string, svgStyle: SvgStyle): string {
+        if (!validateSvg(svgCode)) return "";
+        // Replace currentColor with the selected color
+        const replaced = svgCode.replace(/currentColor/g, svgStyle.svgColor);
+        // Sanitize the SVG before returning
+        return DOMPurify.sanitize(replaced, { USE_PROFILES: { svg: true } });
+    }
+
     return !isEditing ? (
EOF
@@ -9,3 +9,4 @@
import { Check, Pencil, Trash, AlertCircle } from "lucide-react";
import { validateSvg, processedSvg } from "../helpers";
import { validateSvg } from "../helpers";
import DOMPurify from "dompurify";

@@ -86,2 +87,11 @@

// Sanitized processedSvg implementation
function processedSvg(svgCode: string, svgStyle: SvgStyle): string {
if (!validateSvg(svgCode)) return "";
// Replace currentColor with the selected color
const replaced = svgCode.replace(/currentColor/g, svgStyle.svgColor);
// Sanitize the SVG before returning
return DOMPurify.sanitize(replaced, { USE_PROFILES: { svg: true } });
}

return !isEditing ? (
packages/page-blocks/package.json
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/page-blocks/package.json b/packages/page-blocks/package.json
--- a/packages/page-blocks/package.json
+++ b/packages/page-blocks/package.json
@@ -67,3 +67,4 @@
         "react-redux": "^8.1.2",
-        "swr": "^2.3.3"
+        "swr": "^2.3.3",
+        "dompurify": "^3.2.6"
     },
EOF
@@ -67,3 +67,4 @@
"react-redux": "^8.1.2",
"swr": "^2.3.3"
"swr": "^2.3.3",
"dompurify": "^3.2.6"
},
This fix introduces these dependencies
Package Version Security advisories
dompurify (npm) 3.2.6 None
Copilot is powered by AI and may make mistakes. Always verify output.
<p className="font-semibold text-sm">Icon preview</p>
<div
className="w-[100px] h-[60px] flex items-center justify-center"
dangerouslySetInnerHTML={{ __html: svgText }}

Check failure

Code scanning / CodeQL

DOM text reinterpreted as HTML High

DOM text
is reinterpreted as HTML without escaping meta-characters.

Copilot Autofix

AI 8 months ago

To fix the vulnerability, we must sanitize the SVG markup before rendering it with dangerouslySetInnerHTML. The best way is to use a well-known library such as dompurify to sanitize the SVG input. This ensures that only safe SVG markup is rendered, stripping out any potentially dangerous scripts or HTML. The fix involves:

  • Importing dompurify (specifically, the sanitize function).
  • Sanitizing svgText before passing it to dangerouslySetInnerHTML.
  • This can be done by creating a sanitized version of svgText (e.g., sanitizedSvgText) and using that in the render.

All changes are within packages/page-blocks/src/blocks/marquee/admin-widget/item-editor.tsx.


Suggested changeset 2
packages/page-blocks/src/blocks/marquee/admin-widget/item-editor.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/page-blocks/src/blocks/marquee/admin-widget/item-editor.tsx b/packages/page-blocks/src/blocks/marquee/admin-widget/item-editor.tsx
--- a/packages/page-blocks/src/blocks/marquee/admin-widget/item-editor.tsx
+++ b/packages/page-blocks/src/blocks/marquee/admin-widget/item-editor.tsx
@@ -1,2 +1,3 @@
 import React from "react";
+import DOMPurify from "dompurify";
 import {
@@ -69,3 +70,3 @@
                             className="w-[100px] h-[60px] flex items-center justify-center"
-                            dangerouslySetInnerHTML={{ __html: svgText }}
+                            dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(svgText, { USE_PROFILES: { svg: true } }) }}
                         />
EOF
@@ -1,2 +1,3 @@
import React from "react";
import DOMPurify from "dompurify";
import {
@@ -69,3 +70,3 @@
className="w-[100px] h-[60px] flex items-center justify-center"
dangerouslySetInnerHTML={{ __html: svgText }}
dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(svgText, { USE_PROFILES: { svg: true } }) }}
/>
packages/page-blocks/package.json
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/page-blocks/package.json b/packages/page-blocks/package.json
--- a/packages/page-blocks/package.json
+++ b/packages/page-blocks/package.json
@@ -67,3 +67,4 @@
         "react-redux": "^8.1.2",
-        "swr": "^2.3.3"
+        "swr": "^2.3.3",
+        "dompurify": "^3.2.6"
     },
EOF
@@ -67,3 +67,4 @@
"react-redux": "^8.1.2",
"swr": "^2.3.3"
"swr": "^2.3.3",
"dompurify": "^3.2.6"
},
This fix introduces these dependencies
Package Version Security advisories
dompurify (npm) 3.2.6 None
Copilot is powered by AI and may make mistakes. Always verify output.
Comment thread packages/page-blocks/src/blocks/marquee/widget/marquee.tsx Fixed
Comment thread packages/page-blocks/src/blocks/embed/admin-widget.tsx Dismissed
Comment thread packages/page-blocks/src/blocks/embed/admin-widget.tsx Dismissed
Comment thread packages/page-blocks/src/blocks/embed/admin-widget.tsx Dismissed
Comment thread packages/page-blocks/src/blocks/embed/admin-widget.tsx Dismissed
Comment thread packages/page-blocks/src/blocks/embed/admin-widget.tsx Dismissed
Comment thread packages/page-blocks/src/blocks/embed/admin-widget.tsx Dismissed
Comment thread packages/page-blocks/src/blocks/embed/admin-widget.tsx Dismissed
@rajat1saxena rajat1saxena merged commit 996a0f5 into main Aug 11, 2025
7 checks passed
@rajat1saxena rajat1saxena mentioned this pull request Aug 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants